package com.zy.mybatisdemo.controller;

import com.zy.mybatisdemo.common.model.User;
import com.zy.mybatisdemo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Auther: zhangy
 * @Date: 2018/10/4 23:00
 * @Description:
 */
@Controller
public class HelloController {

    @Autowired
    private UserService userService;

    @GetMapping(value = "hello")
    public String hello(ModelMap modelMap){
        List<User> userList = userService.getUsers();
        User one = userList.get(0);
        modelMap.put("user",one);
        return "hello";
     }

     @GetMapping(value = "index")
    public String index(){
        return "homepage/index";
     }
}
